<template>
	<view class="wrap">
		<view class="top"></view>
		<view class="content">
			<view class="title" style="text-align: center;">欢迎登录科院公共安全平台</view>
			<u-form :model="form">
				<u-form-item label="学号" label-width='120'>
					<u-input type="number" v-model="form.userId" />
				</u-form-item>
				<u-form-item label="密码" label-width='120'>
					<u-input v-model="form.password" type="password" />
				</u-form-item>
			</u-form>
			</view>
			<view style="height: 30rpx;clear:both"></view>
			<u-button @click="submit">登录</u-button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				icon: true,
				position: 'center',
				form: {
					userId: '194820211',
					password: '2'
				},
			}
		},
		methods: {
		 	submit() {
				// this.axios.get("http://localhost:8080/front/user/information/1").then((res) => {
				// 	console.log(res.data)
				// })
				this.axios({
				    method:"post",
				    url:"http://localhost:8080/front/user/login?userId="+ this.form.userId + "&password="+this.form.password,
				}).then((res)=>{
					console.log(res.data)
				    if(res.status === 200) {
						// window.sessionStorage.setItem('userId', res.data.data.userId)
						uni.setStorageSync('userId', res.data.data.userId);
						uni.setStorageSync('studentName',res.data.data.name);
						uni.setStorageSync('Id',res.data.data.id);
						uni.reLaunch({
							url: '../home/first'
						})
					}
					//if(res.)
				})
				// this.axios.get("http://localhost:8080/front/user/login").then((response) => {
				//   console.log(response.data)
				// })
			},
		}	

	};
</script>

<style lang="scss" scoped>
	.wrap {
		font-size: 28rpx;

		.content {
			width: 600rpx;
			margin: 80rpx auto 0;

			.title {
				text-align: left;
				font-size: 60rpx;
				font-weight: 500;
				margin-bottom: 100rpx;
			}

			input {
				text-align: left;
				margin-bottom: 10rpx;
				padding-bottom: 6rpx;
			}

			.tips {
				color: $u-type-info;
				margin-bottom: 60rpx;
				margin-top: 8rpx;
			}

			.getCaptcha {
				background-color: rgb(253, 243, 208);
				color: $u-tips-color;
				border: none;
				font-size: 30rpx;
				padding: 12rpx 0;

				&::after {
					border: none;
				}
			}

			.alternative {
				color: $u-tips-color;
				display: flex;
				justify-content: space-between;
				margin-top: 30rpx;
			}
		}

		.buttom {
			.loginType {
				display: flex;
				padding: 350rpx 150rpx 150rpx 150rpx;
				justify-content: space-between;

				.item {
					display: flex;
					flex-direction: column;
					align-items: center;
					color: $u-content-color;
					font-size: 28rpx;
				}
			}

			.hint {
				padding: 20rpx 40rpx;
				font-size: 20rpx;
				color: $u-tips-color;

				.link {
					color: $u-type-warning;
				}
			}
		}
	}
</style>
